package com.xiaoxiong.mami.dao.mapper;

import com.xiaoxiong.mami.dao.daomain.OrderGoods;
import org.apache.ibatis.jdbc.SQL;

public class OrderGoodsSqlProvider {

    public String insertSelective(OrderGoods record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("order_goods");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getOrderId() != null) {
            sql.VALUES("orderId", "#{orderId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsTitle() != null) {
            sql.VALUES("goodsTitle", "#{goodsTitle,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsId() != null) {
            sql.VALUES("goodsId", "#{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsPrice() != null) {
            sql.VALUES("goodsPrice", "#{goodsPrice,jdbcType=DOUBLE}");
        }
        
        if (record.getThumbUrl() != null) {
            sql.VALUES("thumbUrl", "#{thumbUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            sql.VALUES("total", "#{total,jdbcType=INTEGER}");
        }
        
        if (record.getGoodsNumber() != null) {
            sql.VALUES("goodsNumber", "#{goodsNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getPropertyId() != null) {
            sql.VALUES("propertyId", "#{propertyId,jdbcType=INTEGER}");
        }
        
        if (record.getPropertyName() != null) {
            sql.VALUES("propertyName", "#{propertyName,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("createTime", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(OrderGoods record) {
        SQL sql = new SQL();
        sql.UPDATE("order_goods");
        
        if (record.getOrderId() != null) {
            sql.SET("orderId = #{orderId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsTitle() != null) {
            sql.SET("goodsTitle = #{goodsTitle,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsId() != null) {
            sql.SET("goodsId = #{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsPrice() != null) {
            sql.SET("goodsPrice = #{goodsPrice,jdbcType=DOUBLE}");
        }
        
        if (record.getThumbUrl() != null) {
            sql.SET("thumbUrl = #{thumbUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            sql.SET("total = #{total,jdbcType=INTEGER}");
        }
        
        if (record.getGoodsNumber() != null) {
            sql.SET("goodsNumber = #{goodsNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getPropertyId() != null) {
            sql.SET("propertyId = #{propertyId,jdbcType=INTEGER}");
        }
        
        if (record.getPropertyName() != null) {
            sql.SET("propertyName = #{propertyName,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("createTime = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}